﻿@using Yyyg.Models;
@{
    ViewBag.Title = "Addr";
    Layout = "~/Views/UserInfo/_LayoutUserPanel.cshtml";
}
@section head{
    <link href="~/Content/userpanel-addr.css?@Tools.GetRandMax()" rel="stylesheet" />
    <link href="~/Content/addrform.css?@Tools.GetRandMax()" rel="stylesheet" />
    <link href="~/Lib/layui/extension/bioarea/css/common.css" rel="stylesheet" />
    <script src="~/Scripts/src/userpanel-addr.js?v=2104261323"></script>
}
@model List<ReceInfo>
<div class="addrbx">
    <script id="oper" type="text/html">
        <button class="layui-btn layui-btn-xs layui-btn-danger oper_del" lay-event="del">删除</button>
        <button class="layui-btn layui-btn-xs {{d.isdef==1?'layui-btn-disabled':'layui-btn-normal'}} oper_setdef" lay-event="setdef">设为默认</button>
    </script>
    <script id="addrtext" type="text/html">
        <span class="{{d.isdef==1?'isdefaddr':''}}">
            {{d.addr}}
        </span>
    </script>
    <div class="titbar iconfont icon-dizhi">收货地址</div>
    <div class="formbx">
        <form class="addrform layui-form" id="addrpostform" action="/SpAddr/Add" method="post" lay-filter="example">
            <input type="hidden" id="#addrId" name="Id" value="-1" />
            <div>
                <label class="formtit">地址信息:</label>
                <div class="formcont region" id="bioarea-wrap">
                    <div>
                        <select lay-verify="required" style="width: 100px;" class="level-1-select" lay-filter="#bioarea-wrap1level" name="ProvinceCode">
                            <option value="">请选择省</option>
                        </select>
                    </div>
                    <div>
                        <select lay-verify="required" class="level-2-select" lay-filter="#bioarea-wrap2level" name="CityCode">
                            <option value="">请选择市</option>
                        </select>
                    </div>
                    <div>
                        <select lay-verify="required" class="level-3-select" lay-filter="#bioarea-wrap3level" name="CountyCode">
                            <option value="">请选择县</option>
                        </select>
                    </div>
                </div>
            </div>
            <div>
                <label class="formtit">详细地址:</label>
                <div class="formcont">
                    <textarea name="Detarea" required lay-verify="required" id="addr-det" rows="2" cols="20"></textarea>
                </div>
            </div>
            <div>
                <label class="formtit">收货人:</label>
                <div class="formcont">
                    <input autocomplete="off" required lay-verify="required" id="addr-conname" class="layui-form-text" type="text" name="ConsigneeName" maxlength="15" placeholder="长度不超过15个字符" />
                </div>
            </div>
            <div>
                <label class="formtit">手机号码:</label>
                <div class="formcont">
                    <input autocomplete="off" required lay-verify="phone" id="addr-conmob" class="layui-form-text" type="text" name="ConsigneeMobel" maxlength="11" placeholder="请输入11位手机号" />
                </div>
            </div>
            <div>
                <label class="formtit">默认地址:</label>
                <div class="formcont">
                    <input id="addr-isdefault" name="SetDef" checked type="checkbox" lay-text="Yes|No" lay-skin="switch">
                </div>
            </div>
            <div class="btnbox">
                <button id="addr-save" class="layui-btn layui-btn-warm" lay-submit lay-filter="formDemo">保存</button>
            </div>
        </form>
        <script>
            // 组件路径
            layui.config({
                base: '/Lib/layui/extension/bioarea/js/'
            }).extend({
                bioarea: 'bioarea'
            });
            layui.use(['form', 'bioarea'], function () {
                var form = layui.form
                    , bioarea = layui.bioarea

                bioarea.render({
                    elem: '#bioarea-wrap',
                    defaultData: {
                        provinceCode: '',
                        cityCode: '',
                        countyCode: ''
                    },
                    form: form
                })
            });
        </script>
    </div>
    <div class="tablebox">
        <div class="attopbar">地址列表 <span>(还可添加<span class="addrrem">@(20-Model.Count)</span>个)</span> </div>
        <table style="display:none" lay-filter="dtb-addr" id="addrtable" class="layui-table">
            <thead>
                <tr>
                    <th lay-data="{align:'center',field:'number',type:'numbers'}">编号</th>
                    <th lay-data="{field:'id',hide:true}">ID</th>
                    <th lay-data="{field:'isdef',hide:true}">默认的</th>
                    <th lay-data="{field:'addr',width:600,templet:'#addrtext'}">地址</th>
                    <th lay-data="{align:'center',field:'cons',width:100}">收件人</th>
                    <th lay-data="{align:'center',field:'mob',width:120}">手机号</th>
                    <th lay-data="{align:'center',field:'oper',templet:'#oper'}">操作</th>
                </tr>
            </thead>
            <tbody>
                @for (int i = 0; i < Model.Count; i++)
                {
                    var addr = Model[i];
                    <tr data-id="@addr.Id">
                        <td></td>
                        <td>@addr.Id</td>
                        <td>@(addr.IsDefault?"1":"0")</td>
                        <td>@(addr.Proe+addr.City+addr.Area+addr.Det)</td>
                        <td>@addr.Consianee</td>
                        <td>@addr.Mobile</td>
                        <td></td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
</div>

